/**
 * Copyright 2009 by Christian Scheid. This file is part of the switch eclipse plug-in and is licensed under the GPL
 * version 3. Please refer to the URL http://www.gnu.org/licenses/gpl-3.0.html for details.
 */
package org.digitalsoul.switchplugin.actions.store;

import org.digitalsoul.switchplugin.actions.Action;
import org.digitalsoul.switchplugin.actions.ActionType;
import org.digitalsoul.switchplugin.model.ISwitchFile;
import org.digitalsoul.switchplugin.model.SwitchFile;

public class FileSaveAction extends Action {

    private final String fileKey;

    public FileSaveAction(String key) {
        this.fileKey = key;
    }

    @Override
    public ISwitchFile applyAction(ISwitchFile view) {
        ISwitchFile file = new SwitchFile(view);
        FileStore.getInstance().addFile(fileKey, file);
        return file;
    }

    @Override
    public ActionType getType() {
        return ActionType.FILE_SAVE;
    }

    @Override
    public String toString() {
        return fileKey;
    }
}
